<template>
<div class="sms-settings views-container">
  <div class="wlm-form">
    <div class="wlm-form-header">参数设置</div>
    <el-radio-group class="wlm-form-header-radio" v-model="formFormatData.formData.smsId" @change="resetFieldChange">
      <el-radio label="1">阿里云短信</el-radio>
      <el-radio label="2">聚合短信</el-radio>
      <!-- <el-radio :label="3">腾讯云短信</el-radio> -->
    </el-radio-group>
    <div class="wlm-form-notice warning"><i class="el-icon-bell"></i>一次只可以选择一种短信平台</div>
    <section >
      <div class="wlm-form-content">
        <el-form ref="smsSettings" :model="formFormatData.formData" :rules="formFormatData.rules" size="small" label-width="140px" class="retail-form" label-position="right">
          <el-form-item label="App Key" prop="appKey">
            <el-input v-model="formFormatData.formData.appKey">
            </el-input>
          </el-form-item>
          <el-form-item v-if="formFormatData.formData.smsId==1" label="App Secret" prop="appSecret">
            <el-input v-model="formFormatData.formData.appSecret">
            </el-input>
          </el-form-item>
        </el-form>
      </div>
    </section>
  </div>
  <div class="wlm-fixed-btn flex-row flex-align-c flex-justify-c">
    <el-button size="small" type="primary" @click="formFormatSubmit">保存</el-button>
  </div>
</div>
</template>

<script>
// import { userAdd } from '@/api/user'
import {
  smsSet,
  setData
} from '@/api/setting'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Form')],
  name: 'ManagementUserAdd',
  components: {

  },
  directives: {

  },
  data() {
    return {
      formFormatData: {
        key: 'smsSettings',
        api: {
          editForm: {
            api: setData,
            params: {
              key: 'Sms',
              always: true
            }
          },
          submitForm: smsSet
        },
        formData: {
          smsId: '1',
          key: 'Sms',
          appKey: '',
          appSecret: ''
        },
        rules: {
          appKey: [
            { required: true, message: '请输入App Key', trigger: 'blur' }
          ],
          appSecret: [
            { required: true, message: '请输入App Secret', trigger: 'blur' }
          ]
        }
      }
    }
  },
  methods: {
    resetFieldChange() {
      this.resetField('smsSettings')
    }
  }
}
</script>
